package com.cxso.example.client;

import com.cxso.example.enums.ProductClientEnum;
import com.cxso.example.request.ship.HistoryReq;
import com.cxso.example.request.ship.LatestReq;
import com.cxso.example.response.ship.HistoryRes;
import com.cxso.example.response.ship.LatestRes;
import com.cxso.example.sdk.domain.Result;
import com.cxso.example.sdk.http.base.HttpMethod;
import com.cxso.example.sdk.http.client.Client;
import com.cxso.example.sdk.http.core.ChoiceClient;
import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;

@Schema(description = "船舶定位服务")
public class ShipClient extends Client {

    public ShipClient(ChoiceClient choiceClient) {
        super(choiceClient);
    }

    @Schema(description = "历史轨迹")
    public Result<List<HistoryRes>> history(HistoryReq req) {
        return choiceClient.choice(ProductClientEnum.SHARE_PC.getCode()).execute("/v4/api/ship/operateHistory", HttpMethod.POST, req).toList(HistoryRes.class);
    }

    @Schema(description = "实时位置")
    public Result<LatestRes> latest(LatestReq req) {
        return choiceClient.choice(ProductClientEnum.SHARE_PC.getCode()).execute("/v4/api/ship/operateLatest", HttpMethod.POST, req).toEntity(LatestRes.class);
    }
}
